<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<title><s:property value="ev_title" />
</title>
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<link rel="stylesheet" href="${aier_css_url}b.css" />
<link rel="stylesheet" type="text/css" href="${aier_css_url}jp/1.css" />
<link href="${aier_css_url}jq/jq.css" rel="Stylesheet" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}/ui.css" />
<link rel="stylesheet" href="${aier_css_url}comm/text.css" />
<link rel="stylesheet" href="${aier_css_url}admin/admin.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/1.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/afu.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/ui.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/arrayList.js"></script>
<script type="text/javascript" src="${aier_js_url}jc/cj.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}comm/text.js"></script>
</head>
<body style="background-color: #EEF2FB;">
    
    <div style="background-color: #EEF2FB;width: 100%;height: 700px;">
                    <div id="tabs">
                    <ul>
                        <li><a href="#tabs-1">视频设备分派</a></li>
                    </ul>
                    <div id="tabs-1" style="height: 500px;">
                        <div class="d_content" style="height: 500px;overFlow-x: hidden;overFlow-y: auto; ">
					<table style="width:90%;height: 100%;">
						<tr><td><s:action name="proxy_choice" namespace="/zxadmin" executeResult="true"></s:action></td></tr>
						<tr><td>未分派视频设备</td></tr>
						<tr><td><div id="videoUnassignDiv"></div></td></tr>
						<tr><td><div id=icCdate class="jqpage"></div></td></tr>
						<tr><td>已分派视频设备</td></tr>
						<tr><td><div id="videoAllocationDiv"></div></td></tr>
						<tr><td><div id=icCdate1 class="jqpage"></div></td></tr>
					</table>
					</div>
					</div>
					</div>

    </div>


</body>


<script type="text/javascript">
$("#tabs").tabs();
	//显示未分派视频设备信息
		function displayUnassignDiv(p) {
		
			var fun = function(data) {
				var temp = "<table width='100%' border='1' bordercolor='#a0c6e5' style='border-collapse:collapse;' class='tableSiz1'>"
						  +"<tr><td colspan=10 bgcolor='#CCFF00'>设备信息</td></tr><tr><td width='15%'>设备sn</td><td width='15%'>状态</td><td width='15%'>用户名</td>"
						  +"<td width='20%'>密码</td><td width='20%'>URL</td><td width='20%'>设备厂家</td><td colspan=2 width='30%'>操作</td></tr>";	
				if (data.s == 1 && undefined != data.vilist
						&& data.vilist.length > 0) {
					for ( var i = 0; i < data.vilist.length; i++) {
						var tsn = data.vilist[i];
						if (tsn.state == 10) {
							tsn.state = "启用";
						} else if (tsn.state == 0) {
							tsn.state = "停用";
						}
						temp += "<tr><td>"+tsn.sn+"</td><td>"+tsn.state+"</td><td>"+tsn.user+"</td><td>"+tsn.pwd+"</td><td>"+tsn.url+"</td><td>"+data.vs[tsn.supplier]
								+"</td><td><input type='button' class='recordsbut2' value='选中' onclick='selectDIV("+tsn.vid+")'/></td></tr>"
								;
					}
				}
				$("#icCdate").pager({
				pagenumber : data.page,
				pagecount : data.page_count,
				buttonClickCallback : function(page) {
					displayUnassignDiv(page);
				}
			});
				temp += "</table>";
				$("#videoUnassignDiv").html(temp);
			};
			exeAjax(
					ajaxUrl("${aier_url}zxadminjs/videoassign_unassignvideo${aier_suffix}"),
					fun, {
					"page": p,
					});

		}
		
		
		//显示已分派视频设备信息
		function displayAllocationDiv(p) {
		
			var fun = function(data) {
				var temp = "<table width='100%' border='1' bordercolor='#a0c6e5' style='border-collapse:collapse;' class='tableSiz1'>"
						  +"<tr><td colspan=10 bgcolor='#CCFF00'>设备信息</td></tr><tr><td width='15%'>设备sn</td><td width='15%'>状态</td><td width='15%'>用户名</td>"
						  +"<td width='20%'>密码</td><td width='20%'>URL</td><td width='20%'>设备厂家</td><td colspan=2 width='30%'>操作</td></tr>";	
				if (data.s == 1 && undefined != data.vilist
						&& data.vilist.length > 0) {
					for ( var i = 0; i < data.vilist.length; i++) {
						var tsn = data.vilist[i];
						if (tsn.state == 10) {
							tsn.state = "启用";
						} else if (tsn.state == 0) {
							tsn.state = "停用";
						}						
						temp += "<tr><td>"+tsn.sn+"</td><td>"+tsn.state+"</td><td>"+tsn.user+"</td><td>"+tsn.pwd+"</td><td>"+tsn.url+"</td><td>"+data.vs[tsn.supplier]
								+"</td><td><input type='button' class='recordsbut2' value='回收' onclick='Resuse("+tsn.vid+")'/></td></tr>"
								;
					}
				}
				$("#icCdate1").pager({
				pagenumber : data.page,
				pagecount : data.page_count,
				buttonClickCallback : function(page) {
					displayAllocationDiv(page);
				}
			});
				temp += "</table>";
				$("#videoAllocationDiv").html(temp);
			};
			exeAjax(
					ajaxUrl("${aier_url}zxadminjs/videoassign_allocationvideo${aier_suffix}"),
					fun, {
					"page": p,
					});

		}
		
		//分派
		function selectDIV(vid) {

		var fun = function(data) {
			if (1 == data.s) {
				alert("分派成功");
				displayUnassignDiv();
				displayAllocationDiv();
			} else
				alert("分派失败");
		};
		exeAjax(ajaxUrl("${aier_url}zxadminjs/videoassign_updatepid${aier_suffix}"),
				fun, {
					"vid" : vid,
					"pid" : s_pid

				});

	}
	//回收
	function Resuse(vid) {
	
		var fun = function(data) {
			if (1 == data.s) {
				alert("回收成功");
				displayUnassignDiv();
                displayAllocationDiv();
			} else
				alert("回收失败");
		};
		exeAjax(
				ajaxUrl("${aier_url}zxadminjs/videoassign_updatenullpid${aier_suffix}"),
				fun, {
					"vid" : vid,
				});

	}

	displayUnassignDiv();
	displayAllocationDiv();
</script>
</html>